[Enhancement] Validate materialized view subqueries against SQL grammar deny list#5485
Conversation
Implement validateFlintExtensionQuery() to extract and validate the inner SQL subquery from CREATE MATERIALIZED VIEW statements. Previously, this method was a no-op, meaning MV subqueries were not checked against the grammar element deny list. Also adds tumble and hop to the DATE_TIMESTAMP function type to align with Spark's classification of time windowing functions. Signed-off-by: Jialiang Liang <jiallian@amazon.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Description
Implement
validateFlintExtensionQuery()to extract and validate the inner SQL subquery fromCREATE MATERIALIZED VIEWstatements against the grammar element deny list. Previously, this method was a no-op, meaning MV subqueries were not checked.Also adds
tumbleandhopto theDATE_TIMESTAMPfunction type inFunctionType.javato align with Spark's classification of time windowing functions, ensuring these legitimate functions are not incorrectly blocked.Changes
SQLQueryValidator.java— ImplementvalidateFlintExtensionQuery()to extract the MV inner query viaSQLQueryUtils.extractIndexDetails()and validate it through the existingvalidate()method.FunctionType.java— Addtumbleandhopto theDATE_TIMESTAMPfunction type (consistent withwindowandsession_windowalready there).SQLQueryValidatorTest.java— Add tests for MV subquery validation (blocked constructs rejected, legitimate queries pass including window/tumble/hop functions).SparkQueryDispatcherTest.java— Add end-to-end dispatch tests verifying MV queries with window functions are dispatched successfully and blocked constructs are rejected.Issues Resolved
N/A
Check List
--signoff../gradlew :async-query-core:test).By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.